﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;
using F2S.LINQ2LinkedIn.Client.Events;
using F2S.LINQ2LinkedIn.Client.Services;

namespace F2S.LINQ2LinkedIn.Client.ViewModels
{
    public class RequiresAuthorizationViewModel : Screen
    {
        private ILinkedInService _linkedInService;
        private IEventAggregator _eventAggregator;

        public RequiresAuthorizationViewModel(ILinkedInService linkedInService, IEventAggregator eventAggregator)
        {
            _linkedInService = linkedInService;
            _eventAggregator = eventAggregator;
        }

        protected override void OnActivate()
        {
            base.OnActivate();
        }

        public void Authorize()
        {
            
        }

        async public void PerformAuthorization()
        {
            var result = await _linkedInService.Authorize();
            if (result.Success)
            {
                _eventAggregator.Publish(new AuthorizeSucceeded());
            }
        }
    }
}
